package fr.n7.khome.view.renderer;
/* 
 * ColorRenderer.java (compiles with releases 1.2, 1.3, and 1.4) is used by 
 * TableDialogEditDemo.java.
 */

import java.awt.Component;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;

import javax.swing.JLabel;
import javax.swing.JTable;
import javax.swing.table.TableCellRenderer;

public class ImportanceRenderer implements TableCellRenderer, MouseListener{

//	JPanel panel;
//	JSlider slider;
	JLabel label;
	
	public ImportanceRenderer() {
		label = new JLabel("");
		label.setHorizontalAlignment(JLabel.CENTER);
//		super(0,10);
//		slider = new JSlider(0,10);
//		slider.setMajorTickSpacing(5);
//		slider.setMinorTickSpacing(1);
//		slider.setSnapToTicks(true);
//		slider.setPaintTicks(true);
//		slider.setMaximumSize(null);
//		
//		panel = new JPanel(new GridLayout(1,1));
//		panel.add(slider);
//		panel.setBackground(new Color(0,0,3));
		label.addMouseListener(this);
	}

	public Component getTableCellRendererComponent(
			JTable table, Object o,
			boolean isSelected, boolean hasFocus,
			int row, int column) {
		if(o != null){
			if(o instanceof Integer) {
				Integer i = (Integer)o;
				//super.setValue(i);
				label.setText(i+" / 10");
			}
		}
//		panel.remove(slider);
//		panel.add(slider);
//		slider.setSize(panel.getSize());
//		//this.setSize(table.getColumnModel().getColumn(column).getPreferredWidth(), this.getHeight());
//		slider.setPreferredSize(panel.getSize());
//		System.out.println(table.getColumnModel().getColumn(column).getPreferredWidth());
		//panel.setBorder(BorderFactory.createLineBorder(Color.red));
		return label;
	}

	public void mouseClicked(MouseEvent e) {
	}

	public void mouseEntered(MouseEvent e) {
		//resultsTable.editCellAt(((ImportanceRenderer)e.getSource()), column);
	}

	public void mouseExited(MouseEvent e) {
	}

	public void mousePressed(MouseEvent e) {
	}

	public void mouseReleased(MouseEvent e) {
	}
	
}
